// pages/mch/member/detail.js
const App = getApp()

Page({
  data: {
    init: false,

    mem: {},
    showDetail: false,
  },
  onLoad(options) {
    this.execLoad(options.mid)
  },

  execLoad(mid) {
    App.doPost({
      uri: '/app/merchant/customer/detail',
      body: {
        id: mid
      },
      fnSucc: resp => {

        this.setData({
          init: true,
          mem: resp.data,
        })
      }
    })
  },
  toOrder(e) {
    wx.navigateTo({
      url: `/pages/mch/order/index?mid=${this.data.mem.id}`,
    })
  },
  showInfoMet() {
    this.setData({
      showDetail: !this.data.showDetail
    })
  },
  doPreviewIdc(e) {
    let index = e.currentTarget.dataset.index
    let sources = []

    sources.push({
      url: this.data.mem.idc.pica,
      type: 'image'
    })

    sources.push({
      url: this.data.mem.idc.picb,
      type: 'image'
    })

    wx.previewMedia({
      sources: sources,
      current: index
    })
  },
  doPreviewDlc(e) {
    let index = e.currentTarget.dataset.index
    let sources = []

    sources.push({
      url: this.data.mem.dlc.pica,
      type: 'image'
    })

    sources.push({
      url: this.data.mem.dlc.picb,
      type: 'image'
    })

    wx.previewMedia({
      sources: sources,
      current: index
    })
  },
})